#include <bits/stdc++.h>
using namespace std;

int nums[10005][4] = {0};

int main() {
	int n;
	int x, y;
	int ans = -1;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 4; ++j) {
			cin >> nums[i][j];
		}
	}
	cin >> x >> y;
	for (int i = 0; i < n; ++i) {
		if ((nums[i][0] + nums[i][2]) >= x && nums[i][0] <= x) {
			if ((nums[i][1] + nums[i][3]) >= y && nums[i][1] <= y)
				ans = i + 1;
		}
	}
	cout << ans;
	return 0;
}